"""
gevent 只对网络IO生效
"""
import requests
import gevent
from gevent import monkey

monkey.patch_all()


def request_event():
    """请求事件"""
    print('begin')
    requests.get('http://httpbin.org/get')
    print('end')


def main():
    """非阻塞式执行多个请求"""

    # 生成事件清单
    tasks = [
        gevent.spawn(request_event),
        gevent.spawn(request_event),
    ]
    # 把清单加入事件循环队列中
    gevent.joinall(tasks)


main()
